Skip to content

Conversation

@knz
Copy link
Contributor

@knz knz commented Sep 3, 2021

See the individual commits for details.
Supersedes #25

Also a new feature:

When the flag ! is passed in combination with a
precision (e.g. %!.3v), the truncation code now adds an
ellipsis () if truncation has actually occurred.

For example:

printf("%!.3s", "hel") -> ‹hel›
printf("%!.3s", "hello") -> ‹hel…›


This change is Reviewable

@knz knz force-pushed the 20210903-truncation branch 2 times, most recently from 808ab05 to 26eff89 Compare September 3, 2021 11:38
knz added 4 commits September 3, 2021 14:19
The upstream printf code already has support for string
truncation. This commit demonstrates/tests it via unit tests.
This should have been done when format.go moved to a new package.
(Using the refresh.sh script)
When the flag `!` is passed in combination with a
precision (e.g. `%!.3v`), the truncation code now adds an
ellipsis (`…`) if truncation has actually occurred.

For example:

`printf("%!.3s", "hel")` -> `‹hel›`
`printf("%!.3s", "hello")` -> `‹hel…›`
@knz knz force-pushed the 20210903-truncation branch from 26eff89 to afd883e Compare September 3, 2021 12:24
@knz knz requested review from kzh and rimadeodhar September 3, 2021 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant